<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use app\modules\Product\models\ProductRoomPrice;
use app\modules\Order\models\OrderRoom;
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <style type="text/css">
        body{font-family: "Microsoft YaHei" !important;font-size: 9px;line-height: 150%;
        text-align: center;background: #EEE;}
        /** {margin: 0;padding: 0;}*/
        #printBtn{background: #FF9;border-bottom: 1px solid #999;padding: 3px 0;margin-bottom: 10px;text-align: center;}
        #wrapper{
                width: 300mm;
                margin: 0 auto;
                text-align: left;
                background: white;
                padding: 20mm;
                border-top: 1px solid #999;
                border-left: 1px solid #999;
                border-right: 4px solid #333;
                border-bottom: 4px solid #333;
        }
       
    </style>
</head>
<body>



<div id="wrapper">
    <div>
        <table width="100%" border="1" style="border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" colspan="2" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">行程概况</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         产品名称
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         <?=$model->name?>
                     </td>
                </tr>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         出发日期
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         <?=date("Y年m月d日",strtotime($model->go_time))?>
                     </td>
                </tr>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         主要游览国家/地区
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        
                     </td>
                </tr>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         说明
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         本文件作为旅行社和旅游者签署的旅游合同附件，由双方自愿签署，双方对该文件中所列信息有充分认知和理解，如本旅游行程和主合同冲突的，以本“旅游行程”为准。
                     </td>
                </tr>

            </tbody>
        </table>   
    </div>

    <div style="margin-top: 10px;">
        <table width="100%" border="1" style="border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" style="width:1100px;background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">产品特色</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="100%" style="width:200px;background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: left;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         <?=$model->special?>
                     </td>
                </tr>
            </tbody>
        </table>   
    </div>

    <?php 
      $trip = json_decode($model->trip, true);
      ksort($trip);   
      $dates = Yii::$app->dates->prDates($model->go_time, $model->return_time);
    ?>

    <div style="margin-top: 10px;">
       <table width="100%" border="1" style="border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" colspan="2" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">行程表</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         天数/日期
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        行程安排
                     </td>
                </tr>
                <?php foreach($trip as $key=>$val){?>
                <tr>
                     <td width="20%" rowspan=2  style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         <p><?=sprintf("第%s天", $key+1);?></p>
                         <p><?=date('m/d',strtotime($dates[$key]))?></p>
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: left;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                         <?=$val['title']?>
                         <?php if(!empty($val['time1']) || !empty($val['time2'])){?>  邮轮预计<?php if(!empty($val['time1'])){?><?=$val['time1']?> 抵港 <?php };?><?php if(!empty($val['time2'])){?><?=$val['time2']?> 离港 <?php };?>
                         <?php }?>
                         <p style="font-weight:normal;"><?=$val['desc']?></p>
                     </td>
                </tr>
                <tr>
                    <td width="100%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: left;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <span>餐食：<?=!empty($val['eat'])?$val['eat']:'无';?></span>
                        <span style="margin:0 20px;">交通：<?=(isset($val['traffic']) && !empty($val['traffic']))?$val['traffic']:'无';?></span>
                        <span>住宿：<?=!empty($val['room'])?$val['room']:'无';?></span>
                     </td>
                </tr>    
                <?php }?>

            </tbody>
        </table>   
    </div>


    <div style="margin-top: 10px;">
       
         <?php if($model->stock == 1){ ?>
             <table width="300mm" border="1" style="table-layout: fixed;border-collapse: collapse;border: 1px solid #4F81BD;">
                <thead>
                    <tr>
                        <th width="100%" colspan="<?=($type=1) ? 4 : 3?>" style="width:1100px;background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">旅游参考费用</th>
                    </tr>
                    <tr>
                        <th width="40%" style="width:400px;background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">舱型</th>
                        <th width="20%" style="width:200px;background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">楼层</th>
                        <th width="20%" style="width:200px;background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">外卖价/人</th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="20%" style="width:200px;background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">同行价/人</th>
                         <?php }?>
                    </tr>
                </thead>

                <tbody>
                <?php  foreach($model->productRoom as $val){ ?>
                     <?php if($val->show ==1 && !empty($val->price)){ ?>   
                        <?php
                        $name = sprintf("%s%s %s人房",$val->room->name, $val->room->code, $val->people); 
                        ?>
                        <tr>
                            <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><p style="text-align: center;"><?=$name?></p></td>
                            <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><p style="text-align: center;"><?=yii::$app->ceils->getCeils($val->room->ceil)?></p></td>
                            <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color:red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                                <p style="text-align: center;">
                                <?php if(isset($val->sell_out) && $val->sell_out == 1){ ?>
                                    售罄
                                <?php }else{ ?>
                                    <?=$val->price?>
                                <?php }?>
                                </p>
                                </td>
                            <?php if($type == 1){ ?>
                            <td class="in-show" style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color:red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><p style="text-align: center;">
                                <?php if(isset($val->sell_out) && $val->sell_out == 1){ ?>
                                    售罄
                                <?php }else{ ?>
                                    <?=$val->inside_price?>
                                <?php }?>
                                </p>
                            </td>
                            <?php }?>
                        </tr>
                       <?php };?> 
                   
                    <?php };?>
         

                </tbody>
            </table>   
        <?php }elseif($model->stock == 2){?>
        
             <table class="table_price2" border="1" width="300mm" style="table-layout: fixed;border-collapse: collapse;border: 1px solid #4F81BD;">
                <thead>
                    <tr>
                        <th width="100%" colspan="<?=($type=1) ? 7 : 5?>" style="width:1100px;background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">旅游参考费用</th>
                    </tr>
                    <tr>
                        <th width="15%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';"><p style="text-align: left;">名称</p></th>
                        <th width="15%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';"><p style="text-align: left;">第1/2人价格</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="15%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';"><p style="text-align: left;">第1/2人同业价格</p></th>
                        <?php }?>
                        <th width="15%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';"><p style="text-align: left;">第3/4人价格</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="15%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';"><p style="text-align: left;">第3/4人同业价格</p></th>
                        <?php }?>
                        <th width="10%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';"><p style="text-align: left;">单间差</p></th>
                        <th width="15%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';"><p style="text-align: left;">备注</p></th>
                    </tr>

                </thead>
                <tbody>
                <?php if(!empty($model->rooms)){ 
                         $data_rooms = json_decode($model->rooms,true);
                ?>
                <?php   if(is_array($data_rooms)){ ?>
                <?php foreach($data_rooms as $rid=>$val){?>
                        <?php 
                            $use_num = 0;
                            $use_num = OrderRoom::find()->where(['room_id'=>$rid,'product_id'=>$model->id,'status'=>1])->count();
                        ?>
                        <tr>
                        <td style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><?=(!empty($val['name']))?$val['name']:"—";?></td>
                        <td style="background: #337ab7;font-weight: bold;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                 <?=(!empty($val['price']))?$val['price']:"—";?>
                            <?php }?>    
                            </td>
                        <?php if($type == 1){ ?>
                        <td class="in-show" style="background: #337ab7;font-weight: bold;padding: 2mm;color:red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                <?=(!empty($val['inside_price']))?$val['inside_price']:"—";?>
                            <?php }?>      
                            </td>
                        <?php }?>
                        <td style="background: #337ab7;font-weight: bold;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                <?=(!empty($val['price2']))?$val['price2']:"—";?>
                            <?php }?>    
                            </td>
                        <?php if($type == 1){ ?>
                        <td class="in-show" style="background: #337ab7;font-weight: bold;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                 <?=(!empty($val['inside_price2']))?$val['inside_price2']:"—";?>
                            <?php }?>    
                            </td>
                        <?php }?>
                        <td style="background: #337ab7;font-weight: bold;padding: 2mm;color: red;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                  <?=(!empty($val['difference']))?$val['difference']:"—";?>
                            <?php }?>
                            </td>
                        <td style="background: #337ab7;font-weight: bold;border: 1px solid #999;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';"><?=(!empty($val['remark']))?$val['remark']:"—";?></td>
                        </tr>
                <?php };?>
                <?php };?>
                <?php };?>    
                </tbody>
            </table>   

        <?php }?>    
        
    </div>

    <!--相声价格-->
    <div style="width: 100%;text-align: center;">

        <?=$model->cross_talk?>

    </div>

    <div style="margin-top: 10px;">
        <table width="100%" border="1" style="table-layout: fixed;border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">旅游费用包含</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="100%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <?=$model->cost;?>
                     </td>
                </tr>
            </tbody>
        </table>   
    </div>

    <div style="margin-top: 10px;">
        <table width="100%" border="1" style="table-layout: fixed;border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">旅游费用不包含</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="100%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <?=$model->nocost;?>
                     </td>
                </tr>
            </tbody>
        </table>   
    </div>

    <div style="margin-top: 10px;">
        <table width="100%" border="1" style="table-layout: fixed;border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">旅游者行前解约特殊约定</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="100%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <?=$model->cancel;?>
                     </td>
                </tr>
            </tbody>
        </table>   
    </div>

    <div style="margin-top: 10px;">
        <table width="100%" border="1" style="table-layout: fixed;border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">重要提示</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="100%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <?=$model->important;?>
                     </td>
                </tr>
            </tbody>
        </table>   
    </div>

    <div style="margin-top: 10px;">
        <table width="100%" border="1" style="border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" colspan="2" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">风险须知及安全提示书</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        行前解约风险提醒：
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <?=$model->safe_1?>
                     </td>
                </tr>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        人身财产安全警示 ：
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <?=$model->safe_2?>
                     </td>
                </tr>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;text-align: center;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        第三方责任告知：
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        <?=$model->safe_3?>
                     </td>
                </tr>
            </tbody>
        </table>   
    </div>
     
    <div style="margin-top: 10px;">
        <table width="100%" border="1" style="table-layout: fixed;border-collapse: collapse;border: 1px solid #4F81BD;">
            <thead>
                <tr>
                    <th width="100%" colspan="2" style="background: #B8CCE4;font-weight: bold;padding: 2mm;color: #002060;font-size: 9pt;text-align: left;font-family: 'Microsoft YaHei';">旅游者充分阅读和理解本文件所有内容；旅游行程中的购物活动与另行付费项目为双方协商一致共同认可的旅游安排；双方在平等自愿的基础上对本文件内容签署确认。</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                     <td width="20%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        旅游者或旅游者代表（签章）：
                        <br>
                        日期：
                     </td>
                     <td width="80%" style="background: #337ab7;font-weight: bold;padding: 2mm;color: #000;font-size: 9pt;background-color:#F4FAFC;font-family: 'Microsoft YaHei';">
                        旅行社（门市部）（盖章）：
                        <br>
                        经办人及电话：
                        <br>
                        日期:
                     </td>
                </tr>
              
            </tbody>
        </table>   
    </div>
</div>

</body>


<script type="text/javascript" src="/js/html-docx-js/html-docx.js"></script>
<script type="text/javascript" src="/js/html-docx-js/vendor/FileSaver.js"></script>
<script type="text/javascript" src="http://www.xdocin.com/xdoc.js"></script>
<script type="text/javascript">
//var x = document.getElementById("htmlText").value;
//var content = '<html>'+document.getElementById("wrapper").innerHTML+'</html>';
//console.log(x);
//console.log(content);
//XDoc.run(content, "docx", {"标题":"你好"}, "_blank");
</script>
<script type="text/javascript">
    function docxs(argument) {
        var filename = '<?=$model->name?>'+'.docx';
        var content = document.getElementById("wrapper").innerHTML;
        var converted = htmlDocx.asBlob(content);
        saveAs(converted,filename);
    }
</script>
</html>